import axios from 'axios'
import { ChatDto } from "./dto/chat.dto";
import * as process from "process";


export class ChatService {
  async chat(body: ChatDto) {
    const { BAIDU_CHAT_URL } = process.env

    const res = await axios.post(
      `${BAIDU_CHAT_URL}?access_token=${body.token}`,
      JSON.stringify({
        messages: body.messages,
        // disable_search: false,
        // enable_citation: false
      }),
      {
        headers: {
          'Content-Type': 'application/json'
        }
      }
    )

    return res.data
  }
}